package cn.wolfcode.exception;


import cn.wolfcode.domain.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLIntegrityConstraintViolationException;

@RestControllerAdvice
public class GlobalExceptionHandler  {

    @ExceptionHandler(NotLoginException.class)
    public Result handle(NotLoginException e){
        return Result.error(e.getMessage());
    }

    @ExceptionHandler(SQLIntegrityConstraintViolationException.class)
    public Result handle(SQLIntegrityConstraintViolationException e){
        return Result.error("恭喜你完成代码最后一步 好好检查代码错误");
    }

}
